package com.ruoyi.system.service.impl;

import java.util.HashMap;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SQuestionsMapper;
import com.ruoyi.system.domain.SQuestions;
import com.ruoyi.system.service.ISQuestionsService;
import com.ruoyi.common.core.text.Convert;

/**
 * 【请填写功能名称】Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-10-29
 */
@Service
public class SQuestionsServiceImpl implements ISQuestionsService 
{
    @Autowired
    private SQuestionsMapper sQuestionsMapper;

    /**
     * 查询【请填写功能名称】
     * 
     * @param id 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public SQuestions selectSQuestionsById(String id)
    {
        return sQuestionsMapper.selectSQuestionsById(id);
    }

    /**
     * 查询【请填写功能名称】列表
     * 
     * @param sQuestions 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<SQuestions> selectSQuestionsList(SQuestions sQuestions)
    {
        return sQuestionsMapper.selectSQuestionsList(sQuestions);
    }

    /**
     * 新增【请填写功能名称】
     * 
     * @param sQuestions 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertSQuestions(SQuestions sQuestions)
    {
        return sQuestionsMapper.insertSQuestions(sQuestions);
    }

    /**
     * 修改【请填写功能名称】
     * 
     * @param sQuestions 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateSQuestions(SQuestions sQuestions)
    {
        return sQuestionsMapper.updateSQuestions(sQuestions);
    }

    /**
     * 批量删除【请填写功能名称】
     * 
     * @param ids 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteSQuestionsByIds(String ids)
    {
        return sQuestionsMapper.deleteSQuestionsByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除【请填写功能名称】信息
     * 
     * @param id 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteSQuestionsById(String id)
    {
        return sQuestionsMapper.deleteSQuestionsById(id);
    }

    @Override
    public void getMyQuestions(Integer pageNumber, Integer lines, String questionType, String add_user, HashMap<String, Object> hs) {
        pageNumber =  null == pageNumber ? 0 : pageNumber;
        lines = null == lines ? 0 : lines;
        if(null == questionType || "".equals(questionType.trim()) || null == add_user || "".equals(add_user.trim()) ){
            hs.put("DBList", null);
            hs.put("DBAccount", 0);
            return;
        }
         List<SQuestions> list = sQuestionsMapper.getMyQuestions(pageNumber,lines,questionType,add_user);
         Long count = sQuestionsMapper.getMyQuestionsCount(pageNumber,lines,questionType,add_user);
        hs.put("DBList", list);
        hs.put("DBAccount", count);
    }

    @Override
    public void getAllQuestions(Integer pageNumber, Integer lines, String questionType, String begin_time, String end_time, HashMap<String, Object> hs) {
        pageNumber =  null == pageNumber ? 0 : pageNumber;
        lines = null == lines ? 0 : lines;
        if(null == begin_time || "".equals(begin_time.trim())){
            begin_time="1970-01-01 00:00:00";
        }
        if(null == end_time || "".equals(end_time.trim()) ){
            end_time="2100-01-01 00:00:00";
        }
        List<SQuestions> list = sQuestionsMapper.getAllQuestions(pageNumber,lines,questionType,begin_time,end_time);
        Long count = sQuestionsMapper.getAllQuestionsCount(pageNumber,lines,questionType,begin_time,end_time);
        hs.put("DBList", list);
        hs.put("DBAccount", count);
    }

    @Override
    public List<SQuestions> getAllQuestionsExport(String questionType, String begin_time, String end_time) {
       return sQuestionsMapper.getAllQuestionsExport(questionType,begin_time,end_time);
    }
}
